<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="core" uri="http://java.sun.com/jsp/jstl/core" %>

<div id="new_component_main">
    <form:form id="newComponentFormData" commandName="newComponentCommandForm">
        <form:hidden id="dnc_validation_error" path="validationError"/>
        <form:hidden id="dnc_officeId" path="officeId"/>
        <form:hidden path="step"/>

        <form:hidden path="computerId"/>
        <form:hidden path="employeeId"/>


        <table class="table no-border">
            <core:choose>
                <core:when test="${newComponentCommandForm.validationError == false}">
                    <col width="250">
                    <col>
                    <col width="0">
                </core:when>
                <core:otherwise>
                    <col width="250">
                    <col>
                    <col width="150">
                </core:otherwise>
            </core:choose>
            <tbody>
                <tr>
                    <td>Название: </td>
                    <td class="input-control text" data-role="input-control">
                        <form:input style="height: auto" path="description"/>
                    </td>
                    <td><form:errors path="description"/></td>
                </tr>
                <tr>
                    <td>Серийный номер: </td>
                    <td class="input-control text" data-role="input-control">
                        <form:input style="height: auto" path="serial"/>
                    </td>
                    <td><form:errors path="serial"/></td>
                </tr>
                <tr>
                    <td>Тип: </td>
                    <td>
                        <div class="input-control select" data-role="input-control">
                            <form:hidden path="typeId" name="selectType" id="selectType"/>
                        </div>
                    </td>
                    <td><form:errors path="typeId"/></td>
                </tr>
                <tr>
                    <td>Дата покупки: </td>
                    <td>
                        <div class="input-control text" data-role="datepicker" data-locale='ru'>
                            <form:input id="dnc_buy_date" path="buyDateString"/>
                            <button type="button" class="btn-date"></button>
                        </div>
                    </td>
                    <td><form:errors path="buyDateString"/></td>
                </tr>
                <tr>
                    <td>Гарантия до: </td>
                    <td>
                        <div class="input-control text" data-role="datepicker" data-locale='ru'>
                            <form:input path="warrantyEndDateString"/>
                            <button type="button" class="btn-date"></button>
                        </div>
                    </td>
                    <td><form:errors path="warrantyEndDateString"/></td>
                </tr>
                <tr>
                    <td>Офис: </td>
                    <td class="input-control select" data-role="input-control">
                        <select id="dnc_select_office" onchange="officeChanged();">
                            <option value="-1">Выберите офис</option>
                            <core:forEach items="${officeNameList}" var="office">
                                <option value="${office.id}">${office.name}</option>
                            </core:forEach>
                        </select>
                    </td>
                    <td><form:errors path="officeId"/></td>
                </tr>
                <tr>
                    <td>Состояние на момент зачисления:</td>
                    <td class="input-control select" data-role="input-control">
                        <form:select path="status">
                            <form:option selected="selected" value="0">Исправно</form:option>
                            <form:option value="X">Неисправно</form:option>
                            <form:option value="R">В ремонте</form:option>
                        </form:select>
                    </td>
                    <td><form:errors path="status"/></td>
                </tr>
                <td colspan="3">
                    <button id="dnc_next" class="button place-right" type="button" onclick="newComponentNext();">Дальше</button>
                </td>
            </tbody>
        </table>
    </form:form>
</div>